/****************************************************************************
 * Copyright (C) 2011 Maxim Integrated Products, All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL MAXIM INTEGRATED PRODUCTS BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of Maxim Integrated Products
 * shall not be used except as stated in the Maxim Integrated Products
 * Branding Policy.
 *
 * The mere transfer of this software does not imply any licenses
 * of trade secrets, proprietary technology, copyrights, patents,
 * trademarks, maskwork rights, or any other form of intellectual
 * property whatsoever. Maxim Integrated Products retains all ownership rights.
 *
 *     Description: Declares functions for performing operations on the MAXQ
 *                  embedded Flash memory.
 *             $Id: maxq_flash.h 3272 2012-02-27 20:28:47Z jbrodt $
 *
 ********************************************************************************
 */

/** 
* \file
* \brief    MAXQ Embedded Flash Memory Programming Driver
* \details  Provides functions for performing operations on the MAXQ embedded
*           Flash memory.
*/

#ifndef _MAXQ_FLASH_H_
#define _MAXQ_FLASH_H_

/** 
*   \brief    Erases a page of Flash
*   \details  The size of a page is product specific, and can be found in the User's Guide.
*   \param    address   word address in page to erase
*   \returns  #1 if successful, #0 otherwise
*/
int flash_erase_page(unsigned int address);

/** 
*   \brief    Writes the specified word to Flash.
*   \param    address   word address in Flash to write
*   \param    value     value to write to flash
*   \pre      The specified word in Flash must be in the erased state before
*             calling this function.
*   \note     Due to the fixed write size of Flash, this function is not
*             supported on all devices. Consult the datasheet and use
*             flash_write_dbl_word alternately if necessary
*   \returns  #1 if successful, #0 otherwise
*/
int flash_write_word(unsigned int address, unsigned int value);

/** 
*   \brief    Writes the specified two words to Flash.
*   \param    address   word address in Flash to write
*   \param    low_word   value to write to the lower word flash
*   \param    high_word  value to write to the upper word flash
*   \pre      The specified words in Flash must be in the erased state before
*             calling this function.
*   \note     Due to the fixed write size of Flash, this function is not
*             supported on all devices. Consult the datasheet and use
*             flash_write_word alternately if necessary
*   \returns  #1 if successful, #0 otherwise
*/
int flash_write_dbl_word(unsigned int address, unsigned int low_word, unsigned int high_word);

/** 
*   \brief    Reads a word from Flash.
*   \param    address   word address in Flash to read
*   \returns  data read from the specified address in Flash
*/
unsigned int flash_read_word(unsigned int address);

#endif /* _MAXQ_FLASH_H_ */
